package com.example.benefitcommunity.controller;

import com.example.benefitcommunity.entity.BcCommunity;
import com.example.benefitcommunity.entity.BcIdleTrading;
import com.example.benefitcommunity.entity.Result;
import com.example.benefitcommunity.service.BcIdleTradingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 闲置交易表(BcIdleTrading)表控制层
 *
 * @author makejava
 * @since 2025-08-18 20:43:45
 */
@Tag(name = "闲置交易")
@CrossOrigin
@RestController
@RequestMapping("bcIdleTrading")
public class BcIdleTradingController {
    /**
     * 服务对象
     */
    @Resource
    private BcIdleTradingService bcIdleTradingService;

    /**
     * 通过查询数据
     *
     * @param idlename     姓名
     * @param pagenum  页码
     * @param pagesize 页大小
     * @return 数据
     */
    @Operation(description = "闲置交易查询")
    @GetMapping("list")
    public Result<Object> queryByIdleTrading(String idlename, Integer communityid, Integer pagenum, Integer pagesize) {
        return this.bcIdleTradingService.queryByIdleTrading(idlename,  communityid,pagenum, pagesize);
    }

    /**
     * 新增数据
     *
     * @param bcIdleTrading 实体
     * @return 新增结果
     */
    @Operation(description = "新增闲置交易")
    @PostMapping("add")
    public Result<Object> add(@RequestBody BcIdleTrading bcIdleTrading) {
        return this.bcIdleTradingService.insert(bcIdleTrading);
    }

    /**
     * 编辑数据
     *
     * @param bcIdleTrading 实体
     * @return 编辑结果
     */
    @Operation(description = "编辑闲置交易")
    @PutMapping("edit")
    public Result<Object> edit(@RequestBody BcIdleTrading bcIdleTrading) {
        return this.bcIdleTradingService.update(bcIdleTrading);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @Operation(description = "删除闲置交易")
    @DeleteMapping("delete")
    public Result<Object> deleteById(Integer[] id) {
        return this.bcIdleTradingService.deleteById(id);
    }
}

